package tk.xboot.ws.controller;

import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Locale;


@Controller
public class I18nController {

    @Resource
    private MessageSource messageSource;

    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        Locale locale = LocaleContextHolder.getLocale();
        String message = messageSource.getMessage("msg.hello", null, locale);
        return message;
    }




}
